package com.bdqn.tour.servlet.Yml;

import com.bdqn.tour.pojo.Dingdan;
import com.bdqn.tour.service.CityService;
import com.bdqn.tour.service.impl.CityServiceimpl;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/addorde")
public class AddOrder extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置字符编码
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=utf-8");
        //分页参数
        int roomnumbre = Integer.parseInt(req.getParameter("roomnumbre"));
        String contactPhone = req.getParameter("contactPhone");
        String xmname = req.getParameter("xmname");
        String sfztel = req.getParameter("sfztel");
        double prices = Double.parseDouble(req.getParameter("prices"));
        String brand = req.getParameter("brand");
        //获取业务层对象
        CityService cityService = new CityServiceimpl();
        //获取订单对象
        Dingdan dingdan = new Dingdan();
        dingdan.setContactPhone(contactPhone);
        dingdan.setPrices(prices);
        dingdan.setRoomnumbre(roomnumbre);
        dingdan.setSfztel(sfztel);
        dingdan.setXmname(xmname);
        dingdan.setBrand(brand);
        System.out.println(dingdan);
        //接收返回的结果
        int row = cityService.Addorder(dingdan);
        System.out.println(row);
        resp.sendRedirect("/My_fellow_traveler.jsp");
    }
}
